﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
namespace Vehicle.Web.Pages.Pilot
{
    /// <summary>
    /// Copyright (C) M-Tear团队
    /// 文 件 名：Pilot_View.aspx.cs
    /// 版    本：v1.00.0000
    /// 创建标识：2009-08-30  Created by 杨光远 V1.00.0000
    /// 功能说明：查看驾驶员信息页面类
    /// 注意事项：无
    /// 
    /// 更新记录：
    /// 
    /// </summary>
    public partial class Pilot_View : Component.PageBase
    {
        #region ---基本变量实例化---
        Vehicle.BLL.Pilot b_Pilot = new Vehicle.BLL.Pilot();//定义逻辑层变量
        BLL.Log b_Log = new Vehicle.BLL.Log();
        Vehicle.Model.PilotInfo m_PilotInfo = new Vehicle.Model.PilotInfo();//定义实体层变量
        Vehicle.BLL.Vehicles b_Vehicles = new Vehicle.BLL.Vehicles();//定义逻辑层变量
        Vehicle.BLL.Motorcade b_Motorcade = new Vehicle.BLL.Motorcade();//定义逻辑层变量
        #endregion
        #region ---基本方法---
        /// <summary>
        /// 页面加载事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                PilotDataBind();
            }
        }


        public void PilotDataBind()
        {
            if (Request.QueryString["id"] != null && Request.QueryString["id"] != "")
            {


                DataTable dt = b_Motorcade.GetModel(new Vehicle.Model.ComponentsInfo("Pilot", "P_ID", Request.QueryString["id"].ToString(), "P_ID"));
                if (dt.Rows.Count > 0)
                {
                    try
                    {
                        lab_M_ID.Text =b_Motorcade.GetModel(new Vehicle.Model.ComponentsInfo ("Motorcade","M_ID", dt.Rows[0]["M_ID"].ToString(),"M_ID")).Rows[0]["M_Name"].ToString();//绑定车队
                    }
                    catch
                    {
                        lab_M_ID.Text = "无";
                    }
                    try
                    {
                        lab_V_ID.Text = b_Motorcade.GetModel(new Vehicle.Model.ComponentsInfo("Vehicles", "V_ID", dt.Rows[0]["V_ID"].ToString(), "V_ID")).Rows[0]["V_LicenseNum"].ToString(); //绑定车辆
                    }
                    catch
                    {
                        lab_V_ID.Text = "无";
                    }
                    lab_P_Num.Text = dt.Rows[0]["P_Num"].ToString();//绑定驾驶员编号
                    lab_P_Age.Text = dt.Rows[0]["P_Age"].ToString();//年龄
                    lab_P_CarAge.Text = dt.Rows[0]["P_CarAge"].ToString();//车龄
                    dt.Rows[0]["P_Sex"].ToString();
                     if (dt.Rows[0]["P_Sex"].ToString() == "1")//绑定性别
                     {
                         lab_P_Sex.Text = "男";
                     }
                     else
                     {
                         lab_P_Sex.Text = "女";
                     }
                    lab_P_License.Text = dt.Rows[0]["P_License"].ToString();//绑定驾照
                    lab_P_Name.Text = dt.Rows[0]["P_Name"].ToString();//绑定驾驶员名字
                    lab_P_Tel.Text = dt.Rows[0]["P_Tel"].ToString();//驾驶员电话
                    lab_P_Address.Text = dt.Rows[0]["P_Address"].ToString();//联系地址 
                    lab_P_CardID.Text = dt.Rows[0]["P_CardID"].ToString();//驾驶员身份证
                    lab_P_Note.Text = dt.Rows[0]["P_Note"].ToString();//备注
                    lab_P_Time.Text = dt.Rows[0]["P_Time"].ToString();//绑定驾驶员入录时间
                  

                }
                else
                {
                    Common.MessageHelper.AlertBack("该记录已删除!");
                }
            }
            else
            {
                Common.MessageHelper.AlertBack("您的操作有误,请重新尝试!");
            }
        }
 
       
     
        #endregion
    }
}
